<template>
  <el-tag :type="valueType" v-if="propName === 'coupon_use_scope'">{{labelName}}</el-tag>
  <el-tag :type="valueType" v-else-if="propName === 'coupon_exchange_type'">{{couponType}}</el-tag>
</template>

<script>
import {mapGetters} from "vuex";

export default {
  props: ["value", "propName", 'options'],
  computed: {
    ...mapGetters(['dictMap']),
    labelName() {
      if (this.value === 1) {
        return '全场通用';
      }else if (this.value === 2) {
        return '指定商品可用';
      } else {
        return '指定商品不可用';
      } 
    },
    couponType() {
      if (this.value === 1) {
        return '免费兑换';
      }else if (this.value === 2) {
        return '积分兑换';
      }
    },
    options1() {
      if (this.options) {
        return this.options;
      }
      if (!this.propName) {
        return [];
      }
      return this.dictMap[this.propName] || []
    },
    valueLabel() {
      return this.options1.find(it => it.value === this.value || it.value == this.value)?.label;
    },
    valueType() {      
      if (this.value === 1) {
        return '';
      }else if (this.value === 2) {
        return 'warning';
      } else {
        return 'danger';
      } 
    }
  },
};
</script>
